
{template 'common/header'}
{template 'nav'}
{php load()->func('tpl')}
<div class="main">
	{if $op == 'post'}
	<ul class="nav nav-tabs">
		<li><a href="{php echo $this->createWebUrl('announcement', array('op' => 'display','regionid'=>$_GPC['regionid']));}">管理</a></li>
		<li {if intval($_GPC['id'])==0}class="active"{/if}><a href="{php echo $this->createWebUrl('announcement', array('op' => 'post','regionid'=>$_GPC['regionid']));}">创建公告</a></li>
		<li><a href="{php echo $this->createWebUrl('announcement', array('op' => 'setting','regionid'=>$_GPC['regionid']));}">参数设置</a></li>
		{if intval($_GPC['id'])!=0}
		<li class="active"><a href="{php echo $this->createWebUrl('announcement', array('op'=>'post','id'=>$item['id'],'regionid'=>$_GPC['regionid']));}">编辑公告</a></li>
		{/if}
	</ul>
	<form action="" class="form-horizontal" method="post" enctype="multipart/form-data">
		<input type="hidden" name="id" value="{$item['id']}">
		    <div class="panel panel-default">
		  	  <div class="panel-heading">
			    <h3 class="panel-title">使用模板消息，必须是认证的服务号才可以，先到参数设置里面设置对应的场景模板消息ID。</h3>
			  </div>
			  <div class="panel-body">
			  		<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">是否启用模板消息</label>
					    <div class="col-sm-4">
					      <label class="radio-inline">
							  <input type="radio" name="status" id="" value="2" {if $item['status'] == 2 || empty($item['status'])}checked="checked"{/if}> 是
							</label>
							<label class="radio-inline">
							  <input type="radio" name="status" id="" value="1" {if $item['status'] == 1 }checked="checked"{/if}> 否
							</label>
					    </div>
					</div>
					<div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">模板消息类型</label>
					    <div class="col-sm-10">
					      	<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="1" {if $item['enable'] == 1 || empty($item['status'])}checked="checked"{/if} > 停水通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="2" {if $item['enable'] == 2 }checked="checked"{/if}> 燃气通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="3" {if $item['enable'] == 3 }checked="checked"{/if}> 停电通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="4" {if $item['enable'] == 4 }checked="checked"{/if}> 门禁通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="5" {if $item['enable'] == 5 }checked="checked"{/if}> 电梯通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="6" {if $item['enable'] == 6 }checked="checked"{/if}> 停车场通知
							</label>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知标题</label>
					    <div class="col-sm-6">
					      <input type="text" name="title" id='title' value="{$item['title']}" class="form-control" placeHolder="例：您好，很抱歉的告诉您小区将停止供应自来水一段时间。"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知时间</label>
					    <div class="col-sm-6">
					      <input type="text" name="datetime" id='datetime' value="{$item['datetime']}" class="form-control" placeHolder="例：2015年4月25日8：00-2015年4月28日18:00"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知范围</label>
					    <div class="col-sm-6">
					      <input type="text" name="location" id='location' value="{$item['location']}" class="form-control" placeHolder="例：A16栋-A18栋"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知原因</label>
					    <div class="col-sm-6">
					    	<textarea name="reason" id='reason' class="form-control" placeHolder="例：管道检修">{$item['reason']}</textarea>
					    </div>
					</div>
					<div class="form-group">
					    <label for="" class="col-sm-2 control-label">通知备注</label>
					    <div class="col-sm-6">
					    	<input type="text" name="remark" id='remark' value="{$item['remark']}" class="form-control" placeHolder="例：请您提前准备，如有疑问可咨询13770331212"/>
					    </div>
					</div>
					</div>
					 <div class="form-group">
					    <label for="" class="col-sm-2 control-label"></label>
					    <div class="col-sm-10">
							<button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
							<input type="hidden" name="token" value="{$_W['token']}" />
					    </div>
					 </div>
			  </div>
		    </div>
	</form>
<script>
require(['jquery','util'], function($, util){
	$(function(){
		var editor = util.editor($('#reply-add-text')[0]);
	});
});
</script>
{elseif $op == 'display'}
	<ul class="nav nav-tabs">
		<li class="active"><a href="{php echo $this->createWebUrl('announcement', array('op' => 'display','regionid'=>$_GPC['regionid']));}">管理</a></li>
		<li><a href="{php echo $this->createWebUrl('announcement', array('op' => 'post','regionid'=>$_GPC['regionid']));}">创建公告</a></li>
		<li><a href="{php echo $this->createWebUrl('announcement', array('op' => 'setting','regionid'=>$_GPC['regionid']));}">参数设置</a></li>
	</ul>
	<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="" method="post" class="form-horizontal" role="form">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 control-label">公告标题</label>
					<div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
						<input class="form-control" name="title" id="" type="text" value="{$_GPC['title']}">
					</div>
				</div>
				<div class="form-group">
					<div class="pull-right col-xs-12 col-sm-2 col-md-2 col-lg-2">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div style="padding:15px;">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:200px;">公告标题</th>
					<th style="width:100px;">发布日期</th>
					<th style="width:180px;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['title']}</td>
					<td>{php echo date('Y-m-d H:i:s', $item[createtime]);}</td>
					<td>
						<span>
							<a href="{php echo $this->createWebUrl('announcement',array('op'=>'post','id'=>$item['id'], 'regionid' => $regionid))}">
								<i class='glyphicon glyphicon-edit'></i>编辑</a>&nbsp;&nbsp;
								<a href="{php echo $this->createWebUrl('announcement',array('op'=>'delete','id'=>$item['id'], 'regionid' => $regionid))}" onclick="return confirm('此操作不可恢复，确认吗？');"><i class='glyphicon glyphicon-remove-sign'></i>删除</a>
						</span>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
{/if}
	
</div>
{template 'common/footer'}